package cn.edu.stu.syllabus.widgets;

import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import cn.edu.stu.syllabus.R;


/**
 * Created by daidaijie on 2016/8/3.
 */
public class LoadingDialogBuiler {

    public static AlertDialog buildLoadingDialog(Context context, int progressColor, String progressText) {

        RelativeLayout loadingDialogLayout = (RelativeLayout) LayoutInflater.from(context)
                .inflate(R.layout.dialog_loading, null, false);
        TextView mProgressTextView = (TextView) loadingDialogLayout.findViewById(R.id.progressTextView);
        mProgressTextView.setText(progressText);

        ProgressBar loadingProgressBar = (ProgressBar) loadingDialogLayout
                .findViewById(R.id.loadingProgressBar);
        AlertDialog dialog = new AlertDialog.Builder(context)
                .setView(loadingDialogLayout)
                .create();
        loadingProgressBar.getIndeterminateDrawable().setColorFilter(
                progressColor,
                android.graphics.PorterDuff.Mode.SRC_IN);
        dialog.setCancelable(false);

        return dialog;
    }
}
